def interactive_generator():
    """支持双向通信的生成器"""
    received = yield "a"
    print(f"recv: {received}")
    received = yield "b"
    print(f"recv: {received}")
    yield "c"


# 使用示例
gen = interactive_generator()
print(next(gen))
print(gen.send(1))
print(gen.send(2))

""" 
a
recv: 1
b
recv: 2
c
"""